package com.tianpengtech.front.web.tasktemplate;

import java.util.List;

import com.jfinal.aop.Clear;
import com.jfinal.core.Controller;
import com.tianpengtech.common.model.task.Task;
import com.tianpengtech.common.model.task.TaskSource;
import com.tianpengtech.front.web.task.TaskService;

@Clear
public class TaskTemplateController extends Controller{
	private TaskService service = new TaskService();
	public void index(){
		String template = getPara("template","default");
		if(template.equals("default")){
			String ucode = getPara("ucode","c03210fe012c436fb5a1a5eb308d430e");
			String code = getPara("code","");
			int id = getParaToInt(Task.ID,0);
			Task task= Task.dao.findById(id);
			String webUrl = task.getStr(Task.WEB_URL);
			if(task!=null){
				if(webUrl!=null&&!webUrl.startsWith("http")){
					webUrl = "http://"+webUrl;
					task.set(Task.WEB_URL, webUrl);
				}
			}
			setAttr("task",task);
			setAttr("ucode",ucode);
			setAttr("code",code);
			List<TaskSource> source = service.findSourceByTask(task.getInt(Task.ID));
			setAttr("source", source);
		}
		renderTemplate(template+"/index.html");
	}
}
